/*! ******************************************************************************
 *
 * Created on 2021年11月29日
 *
 * Copyright(c) YuZhou Big Data Laboratory CO.,Ltd, 2022.  All rights reserved.
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/

package org.pentaho.di.ui.spoon.navigation.view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.TreeItem;
import org.pentaho.di.ui.spoon.navigation.SpoonRef;

/**
 * 主对象树下面子树实例抽象父类
 * 
 * @author hs@yzbdl.ac.cn
 *
 */
public abstract class MetaTree {

    /**
     * 持有对Spoon的引用,
     */
    private SpoonRef spoonRef;

    /**
     * 所属主对象类别
     */
    private CategoryTree parent;

    /**
     * 主对象实例名称
     */
    private String name;

    /**
     * 节点, 例如转换, 作业
     */
    private TreeItem view;

    public MetaTree(CategoryTree parent, String name) {
        super();
        this.parent = parent;
        this.spoonRef = parent.getSpoonRef();
        this.name = name;
        this.view = new TreeItem(parent.getView(), SWT.NONE);
        this.view.setText(name);
        this.view.setImage(getImage());
    }

    /**
     * 返回节点图标
     * 
     * @return 节点图标
     */
    protected abstract Image getImage();

    // /**
    // * 刷新子节点, 例如数据库连接等
    // */
    // protected abstract void refreshChildItem();

    public CategoryTree getParent() {
        return parent;
    }

    public SpoonRef getSpoonRef() {
        return spoonRef;
    }

    public TreeItem getView() {
        return view;
    }

}
